package edu.uob;

import java.io.File;
import java.io.IOException;

public class TableCreator {

    private static final String databasePath = "." + File.separator + "databases" + File.separator + CmdType.getDbName();

    static String createTable(String tableName) {
        File tableFile = new File(databasePath, tableName + ".tab");

        try {
            if (tableFile.exists()) {
                return "[ERROR]: Table already exists.";
            } else {
                if (tableFile.createNewFile()) {
                    return "[OK]";
                } else {
                    return "[ERROR]: Unable to create table.";
                }
            }
        } catch (IOException e) {
            return "[ERROR]: Exception occurred while creating table.";
        }
    }
}
